<?php

class registeredUsersProtectionComponents extends myComponents{

	public function executeRender(){

		// get node id
		$node = $this->getObject();
			
		if($this->getUser()->isAuthenticated()){

			$rel = Doctrine::getTable('PublicUserGroupVsStructure')->findOneByGroupIdAndStructureId(
				$this->getUser()->getObject()->getPublicUserGroup()->getId(),
				$node->getId()
			);

			if($rel){
				return sfView::NONE;
			}
		}

		$this->getUser()->logOut();
		$this->getAction()->redirect(LinkGen::getInstance(LinkGen::SIGN_IN)->specialLink('login'));
	}
	
}